#ifndef __M_CONSUMER_H__
#define __M_CONSUMER_H__

#include "../mqcommon/logger.hpp"
#include "../mqcommon/helpper.hpp"
#include "../mqcommon/msg.pb.h"

#include <iostream>
#include <unordered_map>
#include <mutex>
#include <memory>
#include <functional>

namespace mmq
{
    using ConsumerCallBack = std::function<void(const std::string, const BasicProperties *bp, const std::string)>;
    struct Consumer
    {
    public:
        using ptr = std::shared_ptr<Consumer>;
    public:
        Consumer()
        {
            DLOG("new Consumer: %p", this);
        }
        Consumer(const std::string &tag, const std::string &qname, bool ack_flag, const ConsumerCallBack &cb)
            : _tag(tag), _qname(qname), _auto_ack(ack_flag), _callback(cb)
        {
            DLOG("new Consumer: %p", this);
        }
        ~Consumer()
        {
            DLOG("del Consumer: %p", this);
        }
    public:
        std::string _tag;           // 消费者唯一标识
        std::string _qname;         // 消费者订阅的队列名称
        bool _auto_ack;             // 自动确认标志
        ConsumerCallBack _callback; // 回调函数
    };

}

#endif